#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
using i128 = __int128;
using namespace std;

void solve(vector<int> a, vector<vector<int>> query) {
    int l, r;
    bool flag = false;
    for (int k = 0; k < query.size(); k++) {
        l = query[k][0] - 1, r = query[k][1] - 1;
        while (l < a.size() && r < a.size() && a[l] == a[r]) {
            l++;
        }
        if (l < r) {
            cout << l + 1 << " " << r + 1 << endl;
            continue;
        }
        if (!flag) cout << -1 << " " << -1 << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--){
        // cin
        int n;
        cin >> n;

        vector<int> a(n);
        for(int i = 0; i < n; i ++) cin >> a[i];

        int q;
        cin >> q;

        vector<vector<int>> query(q, vector<int> {0,0});
        for (int i = 0; i < q; i++) {
            cin >> query[i][0] >> query[i][1];
        }

        solve(a, query);

        cout << endl;
    }

    return 0;
}